using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityGameFramework.Runtime;

namespace LS.Event
{
    [DisallowMultipleComponent]
    [RequireComponent(typeof(EventSystem))]
    public class EventSystemComponent : CustomGameFrameworkComponent
    {
        private EventSystem m_EventSystem;
        private BaseInputModule m_InputModule;

        public EventSystem EventSystem => m_EventSystem;
        public BaseInputModule InputModule => m_InputModule;

        protected override void Awake()
        {
            base.Awake();
            m_EventSystem = GetComponent<EventSystem>();
            m_InputModule = GetComponent<BaseInputModule>();
            
#if ENABLE_INPUT_SYSTEM
            if(m_InputModule == null)
                m_InputModule = gameObject.AddComponent<UnityEngine.InputSystem.UI.InputSystemUIInputModule>();
#else
            if(m_InputModule == null)
                m_InputModule = gameObject.AddComponent<StandaloneInputModule>();
#endif
        }
    }
}
